//
// Created by francklinson on 2021/11/20 AT 20:27.
// May Saint Diana bless you!
//

#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <functional>
#include <climits>
#include <string>

using namespace std;

class Solution {
public:
    string convertToBase7(int num) {
        if (num == 0)
            return "0";
        int x = num;
        if (num < 0)
            x *= -1;
        string ans;
        while (x > 0) {
            int digit = x % 7; // 最后一位
            ans.push_back(digit - 0 + '0');
            x /= 7;
        }
        reverse(ans.begin(), ans.end());
        if (num < 0)
            ans.insert(0, "-");
        return ans;
    }
};

int main() {
    Solution solution;
    cout << solution.convertToBase7(-5) << endl;
    cout << solution.convertToBase7(100) << endl;
    cout << solution.convertToBase7(-7) << endl;
    return 0;
}

